Personal tools

Lua/Tutorials/Weather

From JC2-MP Documentation

< Lua‎ | Tutorials
Jump to: navigation, search


Weather severity values go from 0 to 2. 0 is clear weather with no low-altitude clouds. 2 is the maximum weather possible.

It is region-dependent; it will never snow in desert areas.

Panau's weather is stubborn and will often not do what you tell it to. You can set the weather severity to 2 and it may refuse to rain for a few minutes, even in a rain forest. Then suddenly it will start pouring. Sometimes it starts raining with a value of 0.5.

Changing weather

By World

Lua/Server/World/Functions/SetWeatherSeverity

By Player

Lua/Server/Player/Functions/SetWeatherSeverity

Example

Use '/weather 1.2345' to change the weather for the default world

  1. function PlayerChat(args)
  2. 	local words = args.text:split(" ")
  3. 	if #words ~= 2 then
  4. 		return
  5. 	end
  6.  
  7. 	local value = tonumber(words[2])
  8.  
  9. 	if words[1] == "/weather" and value then
  10. 		DefaultWorld:SetWeatherSeverity(value)
  11. 		Chat:Broadcast("Setting weather to "..value, Color(255, 255, 255))
  12. 		return false
  13. 	else
  14. 		return true
  15. 	end
  16. end
  17.  
  18. Events:Subscribe("PlayerChat", PlayerChat)